**Women's Fertility and Labor Market Responses to a Health Innovation
**Journal of the European Economic Association
**Sonia Bhalotra, Atheendar Venkataramani and Selma Walther
**Replication do-file for Figures

**Figure 4 
use hazarddata.dta, clear

set matsize 10000

macro define control_disease "pbase_tbr pbase_diar pbase_cancer pbase_heartd pbase_mal"

macro define p_b_ses "p_base_ln_pci pln_base_nb_sch_imp_pc pln_base_ed_exp_imp_pc pln_base_nb_hos_imp_pc pln_base_nb_doc_imp_pc pln_base_health_exp_pc"

macro define p_b_flfplit "plit slfp"

foreach var of varlist birth {
   
	local title: variable label `var'
	
    quietly: logit `var' inf1930 inf1931 inf1932 inf1933 inf1934 inf1935 inf1936  inf1938 inf1939 inf1940 inf1941 inf1942 inf1943 mmr1930  mmr1931 mmr1932 mmr1933 mmr1934 mmr1935 mmr1936 mmr1938 mmr1939 mmr1940 mmr1941 mmr1942 mmr1943 i.state i.birthyr_mom i.yearfert i.race hischl college i.order_lb i.timesince_birth  i.censustrend $control_disease $p_b_ses p_year_regis p_year_dregis $p_b_flfplit if sample_nomig==1, robust cluster(state)
	
	margins, dydx(inf1930 inf1931 inf1932 inf1933 inf1934 inf1935 inf1936  inf1938 inf1939 inf1940 inf1941 inf1942 inf1943 mmr1930  mmr1931 mmr1932 mmr1933 mmr1934 mmr1935 mmr1936 mmr1938 mmr1939 mmr1940 mmr1941 mmr1942 mmr1943) subpop(if sample_nomig==1) post atmeans

	local j=1
	local y=1930
    gen j=.
	gen year=.
    qui gen est=0 in 1
    qui gen uCI=0 in 1
    qui gen lCI=0 in 1
	qui gen est_post=0 in 1
    qui gen uCI_post=0 in 1
    qui gen lCI_post=0 in 1
    foreach var of varlist inf1930 inf1931 inf1932 inf1933 inf1934 inf1935 inf1936 {
        replace j=`j' in `j'
		replace year=`y' in `j'
        qui replace est = _b[`var'] in `j'
        qui replace uCI = _b[`var']+1.96*_se[`var'] in `j'
        qui replace lCI = _b[`var']-1.96*_se[`var'] in `j'
        local ++j
		local ++y
    }
	replace year=1937 in 8
	replace est=. if year==1937
	replace uCI=. if year==1937
	replace lCI=. if year==1937
	
	local j=9
	local y=1938
	  foreach var of varlist inf1938 inf1939 inf1940 inf1941 inf1942 inf1943 {
        replace j=`j' in `j'
		replace year=`y' in `j'
        qui replace est_post = _b[`var'] in `j'
        qui replace uCI_post = _b[`var']+1.96*_se[`var'] in `j'
        qui replace lCI_post = _b[`var']-1.96*_se[`var'] in `j'
        local ++j
		local ++y
  
    }
	
  
	sort year
	

    list est year uCI lCI j in 1/14
        	
		twoway scatter est year if year<1937 || rcap lCI uCI year if year<1937 || scatter est_post year if year>1937 || rcap lCI_post uCI_post year if year>1937, scheme(s1mono) title(`title') ytitle("Year*prePneumonia") ylabel(, labsize(small)) xlabel(1930(1)1943 , valuelabel labsize(small)) xtitle("Year") xline(1937, lpattern(shortdash)) yline(0, lpattern(dot))  legend(off)
	graph export "hazardeventstudy_cap_pneu_scatter.pdf", as(pdf) replace
	graph export "hazardeventstudy_cap_pneu_scatter.png", as(png) replace
	

	drop est lCI uCI j year est_post lCI_post uCI_post
	
    }

	
**Figure 5
use stockdata.dta, clear
collapse (mean) statefip base_tbr baserate_under5yr baserate_age25to34 base_inf base_mmr base_diar base_cancer base_heartd base_mal base_ln_pci ln_base_nb_sch_imp_pc ln_base_ed_exp_imp_pc ln_base_nb_hos_imp_pc ln_base_nb_doc_imp_pc ln_base_health_exp_pc year_regis year_dregis lit_1930_stock flfp_1930_stock, by(state)

reg base_inf base_tbr base_mmr base_diar base_cancer base_heartd base_mal base_ln_pci ln_base_nb_sch_imp_pc ln_base_ed_exp_imp_pc ln_base_nb_hos_imp_pc ln_base_nb_doc_imp_pc ln_base_health_exp_pc year_regis year_dregis lit_1930_stock flfp_1930_stock
predict pneu_predict

keep pneu_predict state
rename state statefips

maptile pneu_predict, geo(state) geoid(statefips) fcolor(Blues)
graph export "map_resid.pdf", as(pdf) replace

**Figure 6
*see separate files for model simulations

**Figure 7
use stockdata.dta, clear

*(a)
reg ch1_net b_inf_sulfa_yrs b_mmr_sulfa_yrs  pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis   if  netsample40==1 & no_mig==1 & us_born==1, robust cluster(state)
reg ch2_net b_inf_sulfa_yrs b_mmr_sulfa_yrs  pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis   if  netsample40==1 & no_mig==1 & us_born==1, robust cluster(state)
reg ch3_net b_inf_sulfa_yrs b_mmr_sulfa_yrs  pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis   if  netsample40==1 & no_mig==1 & us_born==1, robust cluster(state)
reg ch4more_net b_inf_sulfa_yrs b_mmr_sulfa_yrs  pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis    if  netsample40==1 & no_mig==1 & us_born==1, robust cluster(state)

*(b)
reg ch1_net b_inf_sulfa_yrs b_mmr_sulfa_yrs pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis   if  completedsample_4050==1 & no_mig==1 & us_born==1, robust cluster(state)
reg ch2_net b_inf_sulfa_yrs b_mmr_sulfa_yrs pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis   if  completedsample_4050==1 & no_mig==1 & us_born==1, robust cluster(state)
reg ch3_net b_inf_sulfa_yrs b_mmr_sulfa_yrs pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis   if  completedsample_4050==1 & no_mig==1 & us_born==1, robust cluster(state)
reg ch4more_net b_inf_sulfa_yrs b_mmr_sulfa_yrs pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis   if  completedsample_4050==1 & no_mig==1 & us_born==1, robust cluster(state)

**Figure 8
use usmortality.dta, clear

twoway ( scatter childless_net base_infrate if year==1930, mlabel(state_code) msymbol(smcircle) mlabvposition(marker1a) ) ( lfit childless_net base_infrate if year==1930), scheme(s1mono) ytitle("Childlessness (net, %)", size(medlarge)) ylabel(, ) xlabel(, valuelabel  ) xtitle("Pneumonia Mortality per 1000", size(medlarge)) legend(off)
graph export "childlessnet_line30_base.pdf", as(pdf) replace
twoway ( scatter nchild base_infrate if year==1930, mlabel(state_code) msymbol(smcircle) mlabvposition(marker1b)) ( lfit nchild base_infrate if year==1930), scheme(s1mono) ytitle("Total fertility, net", size(medlarge)) ylabel(, ) xlabel(, valuelabel  ) xtitle("Pneumonia Mortality per 1000", size(medlarge)) legend(off)
graph export "nchild_line30_base.pdf", as(pdf) replace
twoway ( scatter inlabforce base_infrate if year==1930, mlabel(state_code) msymbol(smcircle)) ( lfit inlabforce base_infrate if year==1930), scheme(s1mono) ytitle("In labor force at time of census, %") ylabel(, ) xlabel(, valuelabel  ) xtitle("Pneumonia Mortality per 1000") legend(off)
graph export "inlabforce_line30_base.pdf", as(pdf) replace
twoway ( scatter evermar base_infrate if year==1930, mlabel(state_code) msymbol(smcircle)) ( lfit evermar base_infrate if year==1930), scheme(s1mono) ytitle("Ever married at time of census, %") ylabel(, ) xlabel(, valuelabel  ) xtitle("Pneumonia Mortality per 1000") legend(off)
graph export "married_line30_base.pdf", as(pdf) replace


**Figure 9
*see separate file

***ONLINE APPENDIX

**Measurement Error Figures

*Figure C.1
use infant_death_ascertainment_1940.dta, clear
histogram no [w = freq], width(1) start(1) freq addlabels

*Figure C.2
use meas_err.dta, clear
ssc install maptile
ssc install spmap
ssc install statastates
maptile_install using "http://files.michaelstepner.com/geo_state.zip"
maptile all_regis if birth_year==1933, geo(state) legfo(%9.0g)

*Figure C.3
use meas_err.dta, clear
graph bar std2_rate_under std2_rate_age if birth_year>=1933&birth_year<=1936, over(quint) bar(1, color(gs4)) bar(2, color(gs12))  legend(label(1 "Child Pneumonia Mort.") label(2 "Adult Pneumonia Mort."))

**Figure C.4
use death_ascertainment_early_late.dta, clear
twoway (line early year, lcolor(gs4) legend(label(1 "Early Registration States") label(2 "Late Registration States"))  ytitle("% Unknown/Missing Cause")) (line late year, lcolor(gs10))

**Figure C.5, C.6
*use base_mortality.dta dataset: this has all mortality rates at state level
*then plot; C.6 uses maptile package

**Figure C.8 - Stock event study
*Childlessness
use stockdata.dta, clear

label var childless_net "Childlessness"
label var nchild "Total number of children"
label var working "Working"
label var married "Married"

foreach var of varlist childless_net  {

local title: variable label `var'
macro define name `var'
reg  `var' inf_1-inf_4 mmr_1-mmr_4 pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis         if  completedsample_all==1 & no_mig==1 & us_born==1, robust cluster(state)

local j=1
	local y=1
    gen j=.
	gen year=0
    qui gen est=0 in 1
    qui gen uCI=0 in 1
    qui gen lCI=0 in 1
	qui gen est_post=0 in 1
    qui gen uCI_post=0 in 1
    qui gen lCI_post=0 in 1
	local j=2
    foreach var of varlist inf_1-inf_4 {
        replace j=-1+`j' in `j'
		replace year=`y' in `j'
        qui replace est = _b[`var'] in `j'
        qui replace uCI = _b[`var']+1.96*_se[`var'] in `j'
        qui replace lCI = _b[`var']-1.96*_se[`var'] in `j'
        local ++j
		local ++y
   
    }
	sort year
	
label define year 0 "0" 1 "1-8" 2 "9-16" 3 "17-24" 4 "25"
    list est year uCI lCI j in 1/10
        
	twoway line est year  if year>0 || rcap lCI uCI year if year>0, scheme(s1mono) ytitle("Sulfa years * prePneumonia") ylabel(, labsize(small)) xlabel(1(1)4 , valuelabel labsize(small)) xtitle("Binned years of exposure") yline(0, lpattern(dot)) legend(off) 
	graph export eventstudy_stock_childless.pdf, as(pdf) replace


	drop est lCI uCI j year est_post lCI_post uCI_post

}

*Number of children
use stockdata.dta, clear

label var childless_net "Childlessness"
label var nchild "Total number of children"
label var working "Working"
label var married "Married"

foreach var of varlist nchild  {

local title: variable label `var'
macro define name `var'
reg  `var' inf_1-inf_4 mmr_1-mmr_4 pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis         if  completedsample_all==1 & no_mig==1 & us_born==1, robust cluster(state)

local j=1
	local y=1
    gen j=.
	gen year=0
    qui gen est=0 in 1
    qui gen uCI=0 in 1
    qui gen lCI=0 in 1
	qui gen est_post=0 in 1
    qui gen uCI_post=0 in 1
    qui gen lCI_post=0 in 1
	local j=2
    foreach var of varlist inf_1-inf_4 {
        replace j=-1+`j' in `j'
		replace year=`y' in `j'
        qui replace est = _b[`var'] in `j'
        qui replace uCI = _b[`var']+1.96*_se[`var'] in `j'
        qui replace lCI = _b[`var']-1.96*_se[`var'] in `j'
        local ++j
		local ++y
   
    }
	sort year
	
    list est year uCI lCI j in 1/10
        
	twoway line est year  if year>0 || rcap lCI uCI year if year>0, scheme(s1mono) ytitle("Sulfa years * prePneumonia") ylabel(, labsize(small)) xlabel(1(1)4 , valuelabel labsize(small)) xtitle("Binned years of exposure") yline(0, lpattern(dot)) legend(off) 
	graph export eventstudy_stock_nchild.pdf, as(pdf) replace


	drop est lCI uCI j year est_post lCI_post uCI_post

}

*Working status
use stockdata.dta, clear

label var childless_net "Childlessness"
label var nchild "Total number of children"
label var working "Working"
label var married "Married"

foreach var of varlist working {

local title: variable label `var'
macro define name `var'
reg  `var' inf_1-inf_4 mmr_1-mmr_4 pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis         if  completedsample_all==1 & no_mig==1 & us_born==1, robust cluster(state)

local j=1
	local y=1
    gen j=.
	gen year=0
    qui gen est=0 in 1
    qui gen uCI=0 in 1
    qui gen lCI=0 in 1
	qui gen est_post=0 in 1
    qui gen uCI_post=0 in 1
    qui gen lCI_post=0 in 1
	local j=2
    foreach var of varlist inf_1-inf_4 {
        replace j=-1+`j' in `j'
		replace year=`y' in `j'
        qui replace est = _b[`var'] in `j'
        qui replace uCI = _b[`var']+1.96*_se[`var'] in `j'
        qui replace lCI = _b[`var']-1.96*_se[`var'] in `j'
        local ++j
		local ++y
   
    }
	sort year
	

    list est year uCI lCI j in 1/10
        
	twoway line est year  if year>0 || rcap lCI uCI year if year>0, scheme(s1mono) ytitle("Sulfa years * prePneumonia") ylabel(, labsize(small)) xlabel(1(1)4 , valuelabel labsize(small)) xtitle("Binned years of exposure") yline(0, lpattern(dot)) legend(off) 
	graph export eventstudy_stock_working.pdf, as(pdf) replace


	drop est lCI uCI j year est_post lCI_post uCI_post

}

*Married status
use stockdata.dta, clear

label var childless_net "Childlessness"
label var nchild "Total number of children"
label var working "Working"
label var married "Married"

foreach var of varlist married  {

local title: variable label `var'
macro define name `var'
reg  `var' inf_1-inf_4 mmr_1-mmr_4 pre_hischl hischl i.race i.state i.birthyr b_tbr_sulfa_yrs b_diar_sulfa_yrs b_cancer_sulfa_yrs b_heartd_sulfa_yrs b_mal_sulfa_yrs Sbase_ln_pci Sln_base_nb_sch_imp_pc Sln_base_ed_exp_imp_pc Sln_base_nb_hos_imp_pc Sln_base_nb_doc_imp_pc Sln_base_health_exp_pc Slit Slfp Syear_regis Syear_dregis         if  completedsample_all==1 & no_mig==1 & us_born==1, robust cluster(state)

local j=1
	local y=1
    gen j=.
	gen year=0
    qui gen est=0 in 1
    qui gen uCI=0 in 1
    qui gen lCI=0 in 1
	qui gen est_post=0 in 1
    qui gen uCI_post=0 in 1
    qui gen lCI_post=0 in 1
	local j=2
    foreach var of varlist inf_1-inf_4 {
        replace j=-1+`j' in `j'
		replace year=`y' in `j'
        qui replace est = _b[`var'] in `j'
        qui replace uCI = _b[`var']+1.96*_se[`var'] in `j'
        qui replace lCI = _b[`var']-1.96*_se[`var'] in `j'
        local ++j
		local ++y
   
    }
	sort year
	
    list est year uCI lCI j in 1/10
        
	twoway line est year  if year>0 || rcap lCI uCI year if year>0, scheme(s1mono) ytitle("Sulfa years * prePneumonia") ylabel(, labsize(small)) xlabel(1(1)4 , valuelabel labsize(small)) xtitle("Binned years of exposure") yline(0, lpattern(dot)) legend(off) 
	graph export eventstudy_stock_married.pdf, as(pdf) replace


	drop est lCI uCI j year est_post lCI_post uCI_post

}



